home *** CD-ROM | disk | FTP | other *** search
/ Freelog 125 / Freelog_MarsAvril2015_No125.iso / Musique / Quod Libet / quodlibet-3.3.0-portable.exe / quodlibet-3.3.0-portable / data / bin / quodlibet / qltk / msg.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2014-12-31  |  4KB  |  81 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.7)
  3.  
  4. from gi.repository import Gtk
  5. from quodlibet import util
  6. from quodlibet.qltk import get_top_parent
  7. from quodlibet.qltk.x import Button
  8. from quodlibet.util.path import fsdecode
  9.  
  10. class Message(Gtk.MessageDialog):
  11.     """A message dialog that destroys itself after it is run, uses
  12.     markup, and defaults to an 'OK' button."""
  13.     
  14.     def __init__(self, kind, parent, title, description, buttons = Gtk.ButtonsType.OK):
  15.         parent = get_top_parent(parent)
  16.         text = "<span weight='bold' size='larger'>%s</span>\n\n%s" % (title, description)
  17.         super(Message, self).__init__(transient_for = parent, modal = True, destroy_with_parent = True, message_type = kind, buttons = buttons)
  18.         self.set_markup(text)
  19.  
  20.     
  21.     def run(self, destroy = True):
  22.         resp = super(Message, self).run()
  23.         if destroy:
  24.             self.destroy()
  25.         return resp
  26.  
  27.  
  28.  
  29. class CancelRevertSave(Gtk.MessageDialog):
  30.     
  31.     def __init__(self, parent):
  32.         title = _('Discard tag changes?')
  33.         description = _('Tags have been changed but not saved. Save these files, or revert and discard changes?')
  34.         text = "<span weight='bold' size='larger'>%s</span>\n\n%s" % (title, description)
  35.         parent = get_top_parent(parent)
  36.         super(CancelRevertSave, self).__init__(transient_for = parent, flags = 0, message_type = Gtk.MessageType.WARNING, buttons = Gtk.ButtonsType.NONE)
  37.         self.add_buttons(Gtk.STOCK_SAVE, Gtk.ResponseType.YES, Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_REVERT_TO_SAVED, Gtk.ResponseType.NO)
  38.         self.set_default_response(Gtk.ResponseType.NO)
  39.         self.set_markup(text)
  40.  
  41.     
  42.     def run(self):
  43.         resp = super(CancelRevertSave, self).run()
  44.         self.destroy()
  45.         return resp
  46.  
  47.  
  48.  
  49. class ErrorMessage(Message):
  50.     '''Like Message, but uses an error-indicating picture.'''
  51.     
  52.     def __init__(self, *args, **kwargs):
  53.         super(ErrorMessage, self).__init__(Gtk.MessageType.ERROR, *args, **kwargs)
  54.  
  55.  
  56.  
  57. class WarningMessage(Message):
  58.     '''Like Message, but uses an warning-indicating picture.'''
  59.     
  60.     def __init__(self, *args, **kwargs):
  61.         super(WarningMessage, self).__init__(Gtk.MessageType.WARNING, *args, **kwargs)
  62.  
  63.  
  64.  
  65. class ConfirmFileReplace(WarningMessage):
  66.     RESPONSE_REPLACE = 1
  67.     
  68.     def __init__(self, parent, path):
  69.         title = _('File exists')
  70.         fn_format = '<b>%s</b>' % util.escape(fsdecode(path))
  71.         description = _('Replace %(file-name)s?') % {
  72.             'file-name': fn_format }
  73.         super(ConfirmFileReplace, self).__init__(parent, title, description, buttons = Gtk.ButtonsType.NONE)
  74.         self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
  75.         save_button = Button(_('_Replace File'), 'document-save')
  76.         save_button.show()
  77.         self.add_action_widget(save_button, self.RESPONSE_REPLACE)
  78.         self.set_default_response(Gtk.ResponseType.CANCEL)
  79.  
  80.  
  81.